<!DOCTYPE HTML>
<html>
<head>
    <#include "../include/easyui.ftl"/>
    <script type="text/javascript">
        $(function(){
            $('#dataList_user').datagrid({
                url:'${ctx}/homestay/user/findUser',
                singleSelect: true,
                fit : true,
                idField : 'userId',
                pagination : true,
                pageSize : 20,
                sortName: 'userId',
                sortOrder: 'desc',
                columns:[[
                    {field:'userId',checkbox:true},
                    {field:'username',title:'账号/工号', sortable:true},
                    {field:'password',title:'密码', sortable:true},
                    {field:'displayName',title:'显示名称', sortable:true},
                    {field:'isManage',title:'是否是管理员', sortable:true},
                    {field:'isEmployee',title:'是否是员工', sortable:true},
                    {field:'deptName',title:'部门', sortable:true},
                    {field:'postName',title:'岗位', sortable:true},
                    {field:'idCard',title:'身份证', sortable:true},
                    {field:'mobilePhone',title:'手机', sortable:true},
                    {field:'email',title:'电子邮箱', sortable:true},
                    {field:'status',title:'状态 ： 正常:1；停用:0；', sortable:true},
                    {field:'createUser',title:'创建人', sortable:true},
                    {field:'createTime',title:'创建时间', sortable:true},
                    {field:'updateUser',title:'修改人', sortable:true},
                    {field:'updateTime',title:'最后一次操作时间', sortable:true}
                ]],
                toolbar:[<#if UserTags.chectButton(0) >{
                    text:'添加',
                    iconCls:'icon-add',
                    handler:function(){
                        update_user();
                    }
                },'-',</#if><#if UserTags.chectButton(1)>{
                    text:'编辑',
                    iconCls:'icon-edit',
                    handler:function(){
                        var obj = Evn.getGridSelected('dataList_user');if(obj==null)return;
                        update_user(obj);
                    }
                },'-',</#if><#if UserTags.chectButton(2)>{
                    text:'删除',
                    iconCls:'icon-remove',
                    handler:function(){
                        var obj = Evn.getGridSelected('dataList_user');if(obj==null)return;
                        delete_user(obj.userId);
                    }
                }</#if>],
                queryParams: $('#search_form_user').serializeObject()
            });
        })
        <#if UserTags.chectButton(0) || UserTags.chectButton(1)>
        function update_user(obj){
            $("#edit_form_user")[0].reset();
            $("#edit_form_user input[name=userId]").val("");
            $('#editDialog_user').dialog({
                title:'用户',
                width:430,
                height:330,
                resizable:true,
                closed: false,
                cache: false,
                modal: true,
                buttons:[{
                    text:'确定',
                    handler:function(){
                        if($('#edit_form_user').form('validate')){
                            $.ajax({
                                type:'post',
                                url:'${ctx}/homestay/user/updateUser',
                                contentType: "application/json",
                                data: JSON.stringify($('#edit_form_user').serializeObject()),
                                dataType : "json",
                                success:function(data){
                                    if(data && data.success){
                                        $.messager.show({title: "提示",msg: "操作成功"});
                                        $('#editDialog_user').dialog('close');
                                        $('#dataList_user').datagrid('reload');
                                    }else{
                                        $.messager.alert('提示',data.msg,'info');
                                    }
                                }
                            });
                        }else{
                            $.messager.alert('提示','请检查表单','info');
                        }
                    }
                },{
                    text:'取消',
                    handler:function(){
                        $('#editDialog_user').dialog('close');
                    }
                }]
            });
            if(obj != null){
                $('#edit_form_user').form('load',obj);
            }
        }
        </#if>
        <#if UserTags.chectButton(2)>
        function delete_user(id){
            $.messager.confirm('请确认','确定删除这条信息?', function(r){
                if(r){
                    $.ajax({
                        url: '${ctx}/homestay/user/deleteUser?id=' + id,
                        type:'get',
                        dataType : "json",
                        success : function(data){
                            if(data.success){
                                $.messager.show({title: "提示",msg: "操作成功"});
                                $('#dataList_user').datagrid('reload');
                            }else{
                                $.messager.alert('提示',data.msg,'info');
                            }
                        }
                    });
                }
            });
        }
        </#if>
        function search_user(){
            $('#dataList_user').datagrid('load', $('#search_form_user').serializeObject());
        }
    </script>
</head>
<body class="easyui-layout">
<div data-options="region:'north',split:true" style="height: 50px;">
    <form id="search_form_user" name="search_form_user" class="baseSearch">
        <label>账号/工号：</label><input name="username" class="easyui-input"/>
        <label>密码：</label><input name="password" class="easyui-input"/>
        <label>显示名称：</label><input name="displayName" class="easyui-input"/>
        <label>是否是管理员：</label><input name="isManage" class="easyui-input"/>
        <label>是否是员工：</label><input name="isEmployee" class="easyui-input"/>
        <label>部门：</label><input name="deptName" class="easyui-input"/>
        <label>岗位：</label><input name="postName" class="easyui-input"/>
        <label>身份证：</label><input name="idCard" class="easyui-input"/>
        <label>手机：</label><input name="mobilePhone" class="easyui-input"/>
        <label>电子邮箱：</label><input name="email" class="easyui-input"/>
        <label>状态 ： 正常:1；停用:0；：</label><input name="status" class="easyui-input"/>
        <label>创建人：</label><input name="createUser" class="easyui-input"/>
        <label>创建时间：</label><input name="createTime" class="easyui-input"/>
        <label>修改人：</label><input name="updateUser" class="easyui-input"/>
        <label>最后一次操作时间：</label><input name="updateTime" class="easyui-input"/>
        <input type="button" value="搜索" onclick="search_user()"/>
        <input type="button" value="重置" onclick="$('#search_form_user')[0].reset();search_user();"/>
    </form>
</div>
<div region="center">
    <table id="dataList_user"></table>
</div>
<#if UserTags.chectButton(0) || UserTags.chectButton(1)>
<div style="display: none;">
    <div id="editDialog_user">
        <form id="edit_form_user" name="edit_form_user">
            <input type="hidden" name="userId" />
            <table>
                <tr>
                    <th>账号/工号：</th>
                    <td><input name="username" class="easyui-validatebox easyui-input" data-options="required:true,validType:['nhtml']" /></td>
                </tr>
                <tr>
                    <th>密码：</th>
                    <td><input name="password" class="easyui-validatebox easyui-input" data-options="required:true,validType:['nhtml']" /></td>
                </tr>
                <tr>
                    <th>显示名称：</th>
                    <td><input name="displayName" class="easyui-validatebox easyui-input" data-options="required:true,validType:['nhtml']" /></td>
                </tr>
                <tr>
                    <th>是否是管理员：</th>
                    <td><input name="isManage" class="easyui-validatebox easyui-input" data-options="required:true,validType:['nhtml']" /></td>
                </tr>
                <tr>
                    <th>是否是员工：</th>
                    <td><input name="isEmployee" class="easyui-validatebox easyui-input" data-options="required:true,validType:['nhtml']" /></td>
                </tr>
                <tr>
                    <th>部门：</th>
                    <td><input name="deptName" class="easyui-validatebox easyui-input" data-options="required:true,validType:['nhtml']" /></td>
                </tr>
                <tr>
                    <th>岗位：</th>
                    <td><input name="postName" class="easyui-validatebox easyui-input" data-options="required:true,validType:['nhtml']" /></td>
                </tr>
                <tr>
                    <th>身份证：</th>
                    <td><input name="idCard" class="easyui-validatebox easyui-input" data-options="required:true,validType:['nhtml']" /></td>
                </tr>
                <tr>
                    <th>手机：</th>
                    <td><input name="mobilePhone" class="easyui-validatebox easyui-input" data-options="required:true,validType:['nhtml']" /></td>
                </tr>
                <tr>
                    <th>电子邮箱：</th>
                    <td><input name="email" class="easyui-validatebox easyui-input" data-options="required:true,validType:['nhtml']" /></td>
                </tr>
                <tr>
                    <th>状态 ： 正常:1；停用:0；：</th>
                    <td><input name="status" class="easyui-validatebox easyui-input" data-options="required:true,validType:['nhtml']" /></td>
                </tr>
                <tr>
                    <th>创建人：</th>
                    <td><input name="createUser" class="easyui-validatebox easyui-input" data-options="required:true,validType:['nhtml']" /></td>
                </tr>
                <tr>
                    <th>创建时间：</th>
                    <td><input name="createTime" class="easyui-validatebox easyui-input" data-options="required:true,validType:['nhtml']" /></td>
                </tr>
                <tr>
                    <th>修改人：</th>
                    <td><input name="updateUser" class="easyui-validatebox easyui-input" data-options="required:true,validType:['nhtml']" /></td>
                </tr>
                <tr>
                    <th>最后一次操作时间：</th>
                    <td><input name="updateTime" class="easyui-validatebox easyui-input" data-options="required:true,validType:['nhtml']" /></td>
                </tr>
            </table>
        </form>
    </div>
</div>
</#if>
</body>
</html>
